<?php
class noticeController extends Controller_Base
{
    public function init()
    {
        $this->noLogInJump();
    }
    
    public function indexAction()
    {
        $this->editAction();
    }

    public function editAction()
    {
    	if(Model_User::getLevelID() != 5){
            $this->notAuthWeb();
            return;
        }
        
        try {
        	$content = Model_Notice::get();
        }catch (Exception $e){
            $this->errExit($e->getTraceAsString(), $e->getMessage());
        }
        $this->setData('title', '编辑通知');
        $this->setData('content', $content);
        $this->setData('notice', true);
        $this->setView('Work/notice.tpl');
    }
    
    public function doEditAction()
    {
        $content = $this->getPost('content',  "");
        try {
        	Model_Notice::modify($content);
            $this->ajaxRet(0, 'success');
            return;
        }catch (Exception $e){
            $this->ajaxRet($e->getCode(), $e->getMessage());
            return;
        }
    }
}